import java.util.Scanner;

public class Test {
    //i==j和i+j = array.length-1;用这俩个来判断这俩条对角线，在同一个循环中用俩个变量来分别求俩对角线和效率更高
    public static int sum(int[][] adr,int a,int b){
        int sums = 0;
        for (int i = 0; i < adr.length; i++) {
            for (int j = 0; j < adr[0].length; j++) {
                if(Math.abs(i-a) == Math.abs(j-b)) {
                    sums += adr[i][j];
                }
            }
        }
        return sums;
    }
    public static void main(String[] args) {
        int[][] adr = new int[3][3];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < adr.length; i++) {
            for (int j = 0; j < adr[0].length; j++) {
                adr[i][j] = sc.nextInt();
            }
        }
        int a,b;//行 列
        System.out.println("从左到右的对角线和为" + sum(adr,0,0));
        System.out.println("从右到左的对角线和为" + sum(adr,0,adr[0].length - 1));
    }
}
